//
//  SLUserNetMgr.m
//  SoccerLottery
//
//  Created by chuanshuangzhang on 15/12/24.
//  Copyright © 2015年 chuanshuangzhang. All rights reserved.
//

#import "SLUserNetMgr.h"

@implementation SLUserNetMgr

+ (void)registerUser:(NSString *)phone password:(NSString *)password userName:(NSString *)userName code:(NSString *)code block:(RequestCallBackBlock)block
{
    NSDictionary *param = @{@"Telephone":phone,@"Password":password,@"UserName":userName,@"Vcode":code};
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:param options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSDictionary *dic = @{@"param":str,@"action":@"Register"};
    [VWebService getRequestAction:@"Register"
                        parameter:dic
                    callbackBlock:^(id result, BOOL status, NSError *error) {
                        block(result,status,error);
                    }];
}

+ (void)login:(NSString *)phone password:(NSString *)password block:(RequestCallBackBlock)block
{
    NSDictionary *param = @{@"Telephone":phone,@"Password":password};
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:param options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSDictionary *dic = @{@"param":str,@"action":@"Login"};
    [VWebService getRequestAction:@"Login"
                        parameter:dic
                    callbackBlock:^(id result, BOOL status, NSError *error) {
                        block(result,status,error);
                    }];

}

+(void)getUserInfo:(NSString *)userId block:(RequestCallBackBlock)block
{
    NSDictionary *param = @{@"UserID":userId};
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:param options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSDictionary *dic = @{@"param":str,@"action":@"GetUserInfo"};
    [VWebService getRequestAction:@"GetUserInfo"
                        parameter:dic
                    callbackBlock:^(id result, BOOL status, NSError *error) {
                        block(result,status,error);
                    }];
}

+(void)modfiyUser:(NSString *)userId password:(NSString *)password userName:(NSString *)userName block:(RequestCallBackBlock)block
{
    NSDictionary *param = @{@"UserID":userId,@"Password":password,@"UserName":userName};
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:param options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSDictionary *dic = @{@"param":str,@"action":@"SetUserInfo"};
    [VWebService getRequestAction:@"SetUserInfo"
                        parameter:dic
                    callbackBlock:^(id result, BOOL status, NSError *error) {
                        block(result,status,error);
                    }];
}

+(void)getVerfiyCode:(NSString *)phone type:(NSString *)type block:(RequestCallBackBlock)block
{
    NSDictionary *param = @{@"Telephone":phone,@"Type":type};
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:param options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSDictionary *dic = @{@"param":str,@"action":@"GetVerifyCode"};
    [VWebService getRequestAction:@"GetVerifyCode"
                        parameter:dic
                    callbackBlock:^(id result, BOOL status, NSError *error) {
                        block(result,status,error);
                    }];

}
+(void)getPassword:(NSString *)phone vcode:(NSString *)code block:(RequestCallBackBlock)block
{
    NSDictionary *param = @{@"Telephone":phone,@"Vcode":code};
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:param options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSDictionary *dic = @{@"param":str,@"action":@"GetPassword"};
    [VWebService getRequestAction:@"GetPassword"
                        parameter:dic
                    callbackBlock:^(id result, BOOL status, NSError *error) {
                        block(result,status,error);
                    }];

}
+(void)setVisit:(RequestCallBackBlock)block
{
    NSDictionary *dic = @{@"action":@"SetVisit"};
    [VWebService getRequestAction:@"SetVisit"
                        parameter:dic
                    callbackBlock:^(id result, BOOL status, NSError *error) {
                        if(block){
                           block(result,status,error);
                        }
                    }];

}
+(void)setPassword:(NSString *)phone password:(NSString *)password block:(RequestCallBackBlock)block
{
    NSDictionary *param = @{@"Telephone":phone,@"Password":password};
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:param options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSDictionary *dic = @{@"param":str,@"action":@"SetPassword"};
    [VWebService getRequestAction:@"SetPassword"
                        parameter:dic
                    callbackBlock:^(id result, BOOL status, NSError *error) {
                        block(result,status,error);
                    }];
}


@end
